
package com.netease.xone.adapter;

import protocol.meta.Subject;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Gallery;

import com.netease.framework.widget.LinkedListAdapter;
import com.netease.xone.R;
import com.netease.xone.widget.LoadingImageView;

public class SubjectBannerAdapter extends LinkedListAdapter<Subject> {

    private Context mContext;
    private int mWidth;
    private int mHeight;

    public SubjectBannerAdapter(Context context) {
        mContext = context;
        mWidth = mContext.getResources().getDisplayMetrics().widthPixels;
        mHeight = mContext.getResources().getDimensionPixelSize(R.dimen.recommdation_banner_height);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            LoadingImageView image = new LoadingImageView(mContext);
            image.setLayoutParams(new Gallery.LayoutParams(mWidth, mHeight));
            image.setServerClipSize(mWidth, mHeight);
            convertView = image;
        }
        LoadingImageView image = (LoadingImageView)convertView;
        image.setLoadingImage(getItem(position).headImageUrl);
        return convertView;
    }

}
